<?php
class Test extends IController
{
    // public function index(){
    //     $this->redirect("adds");
    // }
    public function add_do(){
        $uname=IReq::get("uname");
        $pass = IFilter::act(IReq::get("pass"),'int');
        $model = new IModel("testuser");
        // print_r($pass);
        $arr = array('uname'=>$uname,'pass'=>$pass);

        $model->setData($arr);
        $res = $model->add();
        // $res = $model->add();
        // $result = $model->add();
        if ($res) {
            $this->redirect("show");
        } else {
            $this->redirect("adds.html");
        }
        
    }
    public function show(){
        $model = new IModel("testuser");
        $res = $model->query();
        // echo $res;
        // var_dump($res);
        $this->setRenderData(['res'=>$res]);
        $this->redirect("show");
    }
    public function iptest(){
        // echo "<pre>";
        // print_r($_SERVER);
    }
    public function map(){
        $address=$_POST['addr'];
        $ak="jBhtftnoivHwS5EypucQkZWaomEIuQcN";
        $url="http://api.map.baidu.com/geocoder/v2/?address=$address&output=json&ak=$ak";
        $data=file_get_contents($url);
        $data=json_decode($data,ture);
        echo "<pre>";
        print_r($data);
        $this->redirect("map");
    }
}
?>